package com.boot.learning.beanconvert;

import org.junit.Test;

import com.boot.learning.currencyutils.ObjectConvertUtils;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 属性转换测试demo 
 * 
 * @since JDK1.8
 * @author vencano
 * @date 2017年1月14日 下午3:12:34
 */
public class ApplyDemo {

	private static final ObjectMapper MAPPER = new ObjectMapper();
	
	@Test
	public void testObjectConvert() throws Exception {
		BeanEntity beanDetailEntity = new BeanEntity("b-nam", "b-type");
		System.err.println("source object:" + MAPPER.writeValueAsString(beanDetailEntity));
		BeanMakeDto generateDto = ObjectConvertUtils.convertToClass(beanDetailEntity, BeanMakeDto.class);
		System.err.println("target object:" + MAPPER.writeValueAsString(generateDto));
	}
	
	@Test
	public void testObjectConvert2() throws Exception {
		BeanMakeDto beanMakeDto = new BeanMakeDto();
		beanMakeDto.setBeanName("m-bean-name");
		beanMakeDto.setBeanType("m-bean-type");
		System.err.println("source object:" + MAPPER.writeValueAsString(beanMakeDto));
		BeanEntity beanEntity = ObjectConvertUtils.convertToClass(beanMakeDto, BeanEntity.class);
		System.err.println("target object:" + MAPPER.writeValueAsString(beanEntity));
	}
	
}
